assume cs:codesg,ds:data,ss:stack
data segment
	db 'Welcome to masm!',0,'Welcome to masm!',0,'Welcome to masm!',0,'Welcome to masm!',0,'Welcome to masm!',0
data ends

stack segment
	dd 16 dup(0)
stack ends

codesg segment
start:	mov ax,data
	mov ds,ax
	mov ax,stack
	mov ss,ax
	mov sp,10h
	mov bp,0
	mov dh,8
	mov dl,3
	mov si,0
	mov cx,5
s1:
	push cx
	mov cl,0fch
	call show_str
	add si,11h
	add dh,2
	add dl,4

	pop cx
	loop s1
	
	mov ax,4c00h
	int 21h

	;Show the string end with '0' on screen at the indicated row and coloum  in specific color 
	;dh: row num which between 0 and 24
	;dl: coloum num which between 0 and 79
	;cl: font and background color
	;ds:si the pointer of string to be showed
show_str:
	push es
	push bp
	push si
	push dx

	;set the row num
	mov al,0ah
	mul dh
	add ax,0b800h
	mov es,ax
	;set the coloum num
	mov al,2
	mul dl
	mov bp,ax
	mov dl,cl
	mov ch,0
to_buffer:
	mov cl,ds:[si]
	jcxz break
	mov es:[bp],cl
	mov es:[bp].1,dl
	add bp,2
	inc si
	jmp to_buffer
break:
	pop dx
	pop si
	pop bp
	pop es
	ret
codesg ends
end start